<?php	
	
        
		//Check form was upload_form
		if (array_key_exists('upload_form_submit_check', $_POST)) {

          if (isset ($_FILES['new_image'])){				//has anything been entered into the browse box
              $imagename = $_FILES['new_image']['name'];
			  $imagetype = $_FILES['new_image']['type'];
			  $imagesize = $_FILES['new_image']['size'];//the name to the uploaded image (from browse box)
              $source = $_FILES['new_image']['tmp_name'];	//this is the posted file
              $target = "upload/".$imagename;	//********	../		//target filepath folder/name
			  $project_id = $_POST['project_id'];	
			  //************************need to check if file exists


if (file_exists($target)) {
    echo "<p>The file $filename exists</p>";
	echo '<p><a href="ed03.php?id='.$project_id.'" >click here to continue</a>';
} else {
    
 move_uploaded_file($source, $target);
 
 $imagepath = $imagename;
 $save = "upload/" . $imagepath; //This is the new file you saving = the thumbnail
 $file = "upload/" . $imagepath; //This is the original file
 list($width, $height) = getimagesize($file); //Original file width and height assigned to $width and $height
}
//echo 'project id: '.$project_id;
//echo ' width: '.$width;
//echo ' imagetype: '.$imagetype;
if ($width > 500 && $imagetype=="image/jpeg") {  //should also check image type
	include ('upload_resize_bg.php');
	}
elseif  ($width < 200) {
	include ('upload_marker.php');
	}         
else {
	echo 'image width: '.$width.'too small for background and too large for marker or<br />';
	echo 'wrong type require jpeg for background ';
	}
          } //else file exists
        } //if file submitted
	
?>